Telegram Group & Telegram Channel
Геттеры и сеттеры

В объектно-ориентированных языках распространено использование геттеров и сеттеров для безопасной работы с приватными полями. Например, в C# для этого есть удобная конструкция { get; set; }.

В Python геттер реализуется через декоратор @property, а сеттер в виде @свойство.setter. В примере метод геттера называется age, поэтому декоратор сеттера – @age.setter.

Оба метода должны иметь одинаковое название, по которому можно будет обращаться как к обычному атрибуту.

#классы #property



tg-me.com/python_academy/877
Create:
Last Update:

Геттеры и сеттеры

В объектно-ориентированных языках распространено использование геттеров и сеттеров для безопасной работы с приватными полями. Например, в C# для этого есть удобная конструкция { get; set; }.

В Python геттер реализуется через декоратор @property, а сеттер в виде @свойство.setter. В примере метод геттера называется age, поэтому декоратор сеттера – @age.setter.

Оба метода должны иметь одинаковое название, по которому можно будет обращаться как к обычному атрибуту.

#классы #property

BY Python Academy




Share with your friend now:
tg-me.com/python_academy/877

View MORE
Open in Telegram


Python Academy Telegram | DID YOU KNOW?

Date: |

Launched in 2013, Telegram allows users to broadcast messages to a following via “channels”, or create public and private groups that are simple for others to access. Users can also send and receive large data files, including text and zip files, directly via the app.The platform said it has more than 500m active users, and topped 1bn downloads in August, according to data from SensorTower.

The SSE was the first modern stock exchange to open in China, with trading commencing in 1990. It has now grown to become the largest stock exchange in Asia and the third-largest in the world by market capitalization, which stood at RMB 50.6 trillion (US$7.8 trillion) as of September 2021. Stocks (both A-shares and B-shares), bonds, funds, and derivatives are traded on the exchange. The SEE has two trading boards, the Main Board and the Science and Technology Innovation Board, the latter more commonly known as the STAR Market. The Main Board mainly hosts large, well-established Chinese companies and lists both A-shares and B-shares.

Python Academy from nl


Telegram Python Academy
FROM USA